<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

    <body>
        <ui:composition template="../templates/default3.xhtml">
            <ui:define name="content">
                <h:form id="rawMaterialPurchaseOrders" binding="#{rawMaterialPurchasingManagerBean.loadSearchRawMaterialDeliveries}">
                    <p:panel header="Raw Material Deliveries" id="rawMaterialDeliveriesPanel">
                        <p:messages />

                        <p:dataTable id="rmDeliveries" var="rmDelivery" value="#{rawMaterialPurchasingManagerBean.rawMaterialDeliveries}" 
                                     update="rawMaterialDeliveriesPanel" paginator="true" rows="10"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                     selection="#{rawMaterialPurchasingManagerBean.selectedRawMaterialDelivery}"
                                     selectionMode="single"
                                     emptyMessage="No raw material deliveries found with given criteria."
                                     rowStyleClass="#{rmDelivery.expiryDate ge 
                                                      rawMaterialPurchasingManagerBean.todayTimestamp
                                                      and rmDelivery.expiryDate le 
                                                      rawMaterialPurchasingManagerBean.todayTimestampPlus60 ? 'dOrange' : null }">    
                            <p:column filterBy="#{rmDelivery.deliveryNumber}" headerText="Delivery No." filterMatchMode="contains">  
                                <h:outputText value="#{rmDelivery.deliveryNumber}" />  
                            </p:column> 
                            <p:column filterBy="#{rmDelivery.supplier.company}" headerText="Supplier" filterMatchMode="contains">  
                                <h:outputText value="#{rmDelivery.supplier.company}" />  
                            </p:column> 
                            <p:column filterBy="#{rmDelivery.warehouseZone.zoneName}" headerText="Storage Zone" filterMatchMode="contains">  
                                <h:outputText value="#{rmDelivery.warehouseZone.zoneName}" />  
                            </p:column>
                            <p:column filterBy="#{rmDelivery.materialRequired.rawMaterial.name}" headerText="Material" filterMatchMode="contains">  
                                <h:outputText value="#{rmDelivery.materialRequired.rawMaterial.name}" />  
                            </p:column>
                            <p:column headerText="Receipt Date">  
                                <h:outputText value="#{rmDelivery.receivedDate}">
                                    <f:convertDateTime pattern="dd-MMM-yyyy" timeZone="#{defaultManagerBean.tz}"/>
                                </h:outputText>
                            </p:column>    
                            <p:column headerText="Expiry Date">  
                                <h:outputText value="#{rmDelivery.expiryDate}">
                                    <f:convertDateTime pattern="dd-MMM-yyyy" timeZone="#{defaultManagerBean.tz}"/>
                                </h:outputText>
                            </p:column>  
                        </p:dataTable>
                        <table class="table-submit">
                            <tr>
                                <td align="center">
                                    <p:commandButton id="btnViewRMD" value="View Delivery" 
                                                     title="View the selected raw material delivery." ajax="true"
                                                     update="rawMaterialDeliveriesPanel"
                                                     actionListener="#{rawMaterialPurchasingManagerBean.viewDelivery}" />    
                                </td>
                            </tr>
                        </table>
                    </p:panel>
                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>
